package com.itheima.mapper;

import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Encounter
 * @date 2024/10/02 17:10<br/>
 */
@Mapper
public interface CheckItemMapper
    {
        /**
         * 新增检查项
         *
         * @param checkItem 检查项
         * @return int 新增条数
         */
        @Insert("insert into t_checkitem(code, name, sex, age, price, type, attention, remark) " +
                "values (#{code} ,#{name} ,#{sex} ,#{age} ,#{price} ,#{type} ,#{attention} ,#{remark})")
        int add(CheckItem checkItem);
        
        /**
         * 分页查询
         *
         * @return {@link List }<{@link CheckItem }>
         */
        @Select("select id, code, name, sex, age, price, type, attention, remark from t_checkitem")
        List<CheckItem> query();
        
        /**
         * 根据id查询
         *
         * @param id 检查项id
         * @return {@link CheckItem }
         */
        @Select("select id, code, name, sex, age, price, type, attention, remark from t_checkitem where id = #{id}")
        CheckItem queryById(Integer id);
        
        /**
         * 删除由id
         *
         * @param id 检查项id
         * @return int 删除的条数
         */
        @Delete("delete from t_checkitem where id = #{id}")
        int deleteById(Integer id);
        
        /**
         * 修改检查项
         *
         * @param checkItem 检查项
         * @return int 修改成功的数据条数
         */
        int update(CheckItem checkItem);
    }
